From: http://blog.csdn.net/suwei19870312/article/details/6665305
In some large projects, there may be dozens of basic classes, which are inevitably referenced by each other (not satisfying the inheritance relationship, but composite relationship ).
<> First, find the header file in the system directory. If the file is not found in the current directory. So use this method like standard header files stdio. h and stdlib. h.
"" Is first searched in the current directory. If it cannot be found,
The role of file inclusion
The so-called "file contains" processing means that a source file can include the entire contents of another source file, which will be included in the document. C + + provides the #include command to implement the "file
In C + + code, include is required when a file needs to use the classes, structs, constants, and so on that are defined in another file.
When using include, you can have no rules, random include. But the result of this is not looping nesting, which
To put it simply:. h is the header file for standard C, and No. h is the standard C + + header file, both of which are header files. The reason for the difference between these two forms is that the development history of C + + is decided, just
The include (), require () statement contains and runs the specified file. The two structures are exactly the same on the containing file, and the only difference is the handling of the error. The require () statement stops when it encounters a
C ++ File include rule constant definition
To sum up, C ++'s function declaration, variable declaration, and class definition are written in the header file, while function implementation, variable definition, and class method implementation are
The usage of include and require in PHP is different from that in PHP. include () and require () have the same functions. include (include_once) and require (require_once) both read the included file code to the specified location, but there is a
In a powerful language such as C ++ programming language, there is a lot of profound content that deserves further research. For example, the C ++ include mechanism introduced today is one of the hard-to-understand aspects. Let's take a look at this.
Two cases are differentiated:1, #include <> compiler will only go to the System file directory to find, can not find the error.2, #include "" The compiler will look in the user directory first, then to the compiler set directory to find, and finally
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.